import request from "@/utils/request";

export function getPostPageList(params) {
    return request({
        url: "/post/list",
        method: 'get',
        params: params
    })
}
export function addPost(data) {
    return request({
        url: '/post',
        method: 'post',
        data,
        headers: {
            isToken: true
        }
    })
}
export function getPostDetail(params) {
    return request({
        url: '/post/detail/' + params.id,
        method: 'get',
    })
}
export function updateViewCount(params) {
    return request({
        url: '/post/viewCount',
        method: 'put',
        headers:{
            isToken:true
        },
        params
    })
}

export function likePost(id) {
    return request({
        url: '/post/like/' + id,
        method: 'put',
        headers: {
            isToken: true
        }
    })
}

export function cancelLike(id) {
    return request({
        url: '/post/like/cancel/' + id,
        method: 'delete',
        headers: {
            isToken: true
        }
    })
}
export function isLiked(postId) {
    return request({
        url: '/post/isLiked',
        method: 'get',
        headers: {
            isToken: true
        },
        params: { postId: postId }
    })
}
export function getRecommendPost(params){
    return request({
        url:'/post/recommend',
        method:'get',
        headers:{
            isToken:true
        },
        params
    })
}
export function searchPost(params){
    return request({
        url:'/post/search',
        method:'get',
        params
    })
}
export function isMyPost(params){
    return request({
        url:'/post/isMy',
        method:'get',
        headers:{
            isToken:true
        },
        params
    })
}
export function updateMyPost(data){
    return request({
        url:'/post',
        method:'put',
        headers:{
            isToken:true
        },
        data
    })
}
export function deleteMyPost(params){
    return request({
        url:'/post',
        method:'delete',
        headers:{
            isToken:true
        },
        params
    })
}
export function rewardPost(params){
    return request({
        url:'/post/reward',
        method:'post',
        headers:{
            isToken:true
        },
        params
    })
}
export function myPostList(){
    return request({
        url:'/post/myList',
        method:'get',
        headers:{
            isToken:true
        },
    })
}